#include "graph.h"
/*
void Inspect(int R);
void Answer(int D, int A);
void Move(int I, int V);
int NumberOfRoads();
int LastRoad();
int Color();

*/
#include <bits/stdc++.h>
using namespace std;
const int N = 210;
vector<pair<int, int> > g[N];
int dep[N], cnt = 1, deg[N], n, col[N];
int out[N][N], fs[N][N], fae[N], mdep, anc[N], to[N][N];
int e[N][N];

void dfss(int x, int fa){
	dep[x] = dep[fa] + 1;
	mdep = max(mdep, dep[x]);
	deg[x] = NumberOfRoads();
	fae[x] = LastRoad();
	anc[x] = fa;
	out[x][fae[x]] = -1;
	col[x] = 3;
	for(int i = 1; i <= deg[x]; ++ i){
		if(i == fae[x]) continue;
		Move(i, col[x]);
		if(Color() != 1){
			int tmp = Color();
			// printf("get fs %d %d %d\n", x, i, tmp);
			Move(LastRoad(), tmp);
			if(tmp == 3) fs[x][LastRoad()] = 1;
		} else {
			// printf("get sb %d %d\n", x, i);
			fs[x][i] = -1;
			out[x][i] = ++ cnt;	
			g[x].push_back(make_pair(out[x][i], i));
			dfss(out[x][i], x);
		}
	}
	if(x != 1){
		Move(fae[x], 2);
	}
}
void dfs(int x, int fa, int cj){
	// printf("%d\n", x);
	col[x] = ((dep[x] >> cj) & 1) + 2;
	for(int i = 1; i <= deg[x]; ++ i){
		if(i == fae[x]) continue;
		if(fs[x][i] == 1){
			// printf("fs %d %d\n", x, i);
			Move(i, col[x]);
			int tmp = Color();
			// printf("%d\n", LastRoad());
			Move(LastRoad(), tmp);
			out[x][LastRoad()] += (tmp - 2) << cj;
		} else if(fs[x][i] == -1){
			// printf("sb %d %d %d\n", x, NumberOfRoads(), i);
			Move(i, col[x]);
			dfs(out[x][i], x, cj);
		}
	}
	if(x != 1){
		// printf("fz %d %d\n", x, fae[x]);
		Move(fae[x], Color());
	}
}

void Inspect(int R) {
	cnt = 1;
	mdep = 0;
	dep[0] = -1;
	// dfs(1, 0);
	dfss(1, 0);
	// n = cnt;
	// for(int i = 1; i <= n; ++ i){
		// printf("%d %d %d\n", i, dep[i], col[i]);
	// }
	// return ;
	// puts("-----------");
	dfs(1, 0, 0);
	for(int i = 1; (1 << i) <= mdep; ++ i){
	// puts("-----------");
		dfs(1, 0, i);
	}
	n = cnt;
	memset(e, 0x3f, sizeof(e));
	for(int i = 1; i <= n; ++ i){
		e[i][i] = 0;
	}
	for(int i = 2; i <= n; ++ i){
		e[i][anc[i]] = e[anc[i]][i] = 1;
		// printf("shubian %d %d\n", i, anc[i]);
		for(int j = 1; j <= deg[i]; ++ j){
			if(fs[i][j] == 1 && out[i][j] < dep[i]){
				int x = i;
				while(dep[x] > out[i][j]) x = anc[x];
				e[i][x] = e[x][i] = 1;
				// printf("feishub %d %d\n", i, x);
			}
		}
	}
	for(int k = 1; k <= n; ++ k){
		for(int i = 1; i <= n; ++ i){
			for(int j = 1; j <= n; ++ j){
				e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
			}
		}
	}
	static int ans[N];
	memset(ans, 0, sizeof(ans));
	for(int i = 1; i <= n; ++ i){
		for(int j = i + 1; j <= n; ++ j){
			++ ans[e[i][j]];
		}
	}
	for(int i = 1; i <= R; ++ i){
		Answer(i, ans[i]);
	}
	return;
}
/*
void dfs(int x, int fa, int cj){
	// printf("get %d %d\n", x, Color());
	if(cj == 0){
		dep[x] = dep[fa] + 1;
		mdep = max(mdep, dep[x]);
		deg[x] = NumberOfRoads();
		fae[x] = LastRoad();
		anc[x] = fa;
		out[x][fae[x]] = -1;
	}
	col[x] = ((dep[x] >> cj) & 1) + 2;
	// printf("%d %d %d %d\n", fa, x, deg[x], fae[x]);
	for(int i = 1; i <= deg[x]; ++ i){
		if(i == fae[x]) continue;
		Move(i, col[x]);
		if((cj == 0 && Color() != 1 && fs[x][i] == 0) || (cj && fs[x][i] == 1)){
			// fs[i][LastRoad()] = -1;
			// printf("%d %d\n", x, Color());
			// printf("%d %d %d\n", x, LastRoad(), Color());
			int tmp = Color();
			// printf("fs %d %d %d\n", x, i, tmp);
			Move(LastRoad(), tmp);
			out[x][LastRoad()] += (tmp - 2) << cj;
			fs[x][LastRoad()] = 1;
		} else {
			// printf("ss %d %d\n", x, i);
			if(cj == 0){
				out[x][i] = ++ cnt;	
				g[x].push_back(make_pair(out[x][i], i));
			}
			dfs(out[x][i], x, cj);
		}
	}
	// printf("%d %d %d\n", x, fae[x], Color());
	if(x != 1){
		Move(fae[x], Color());
	}
}
*/
